package com.heima.media.config;

import com.heima.media.interceptor.UserInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.handler.UserRoleAuthorizationInterceptor;

/**
 * 拦截器 有了它才能生效
 */
@Configuration // 申明配置类
public class WebMvcConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new UserInterceptor()) // 指定自定义的拦截器
                .addPathPatterns("/**"); // 指定需要拦截的路径, 拦截所有
    }
}
